﻿function GetDeleteAfrowids(page_id, row_id) {
    //alert(row_id);

    var id = "ct100$" + page_id + "_af_row_id_" + row_id;
    if (document.getElementById(id) != null) {
        // alert("hidden field found");
    }


    // alert(id);




    //        var id= "ctl00__sys" + page_id + "_RowCount";
    //        var obj=document.getElementById(id);
    //        
    //        id= "ctl00_ContentPlaceHolder3_hih_DelPageId";
    //        obj=document.getElementById(id);
    //        obj.value = page_id;
    //        
    //        id= "ctl00_ContentPlaceHolder3_hih_DelRowId";
    //        obj=document.getElementById(id);
    //        obj.value = row_id;
    return true;

}

function updateclickstatus(eventtype) {
    ////    if(document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount")!=null)
    ////    {
    ////         alert("IE");
    ////         if(eventtype == "add")
    ////         {
    ////            document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount").value = "add";
    ////         }
    ////         else if(eventtype == "del")
    ////         {
    ////            document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount").value = "del";
    ////         }
    ////         
    ////         //alert(eventtype);
    ////         
    ////    }

    if (document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount") != null) {
        //alert("Firefox");
        if (eventtype == "add") {
            //alert("add");
            document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount").value = "add";

            if (document.getElementById("ctl00_ContentPlaceHolder3_hfdoPostback") != null) {
                document.getElementById("ctl00_ContentPlaceHolder3_hfdoPostback").value = "addyes";
            }
        }
        else if (eventtype == "del") {
            document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount").value = "del";
            if (document.getElementById("ctl00_ContentPlaceHolder3_hfdoPostback") != null) {
                document.getElementById("ctl00_ContentPlaceHolder3_hfdoPostback").value = "delyes";
            }
        }

        //alert(eventtype);
        //removed by sanal on Feb 26, 2010
        //setTimeout("transdoc_refreshTotalFieldsWithArg(true)",500);
        //setTimeout("transdoc_refreshTotalFieldsWithArg(true)",2000);
        //setTimeout("transdoc_refreshTotalFieldsWithArg(true)",5000);
    }


}

function seteventsender(sender) {
    ////    //alert("inside function");
    ////        if(document.getElementById("ctl00$ContentPlaceHolder3$hfeventsender")!=null)
    ////        {
    ////       // alert(sender);
    ////            if(sender !="")
    ////            {
    ////                document.getElementById("ctl00$ContentPlaceHolder3$hfeventsender").value = sender;
    ////            }
    ////        }

    if (document.getElementById("ctl00_ContentPlaceHolder3_hfeventsender") != null) {
        // alert(sender);
        if (sender != "") {
            document.getElementById("ctl00_ContentPlaceHolder3_hfeventsender").value = sender;
        }
    }
}


function validaterequiredfields() {
    var pageid = "";
    var rowcount = "";
    if (document.getElementById("ctl00_ContentPlaceHolder3_hfchildpageid") != null) {
        if (document.getElementById("ctl00_ContentPlaceHolder3_hfchildpageid").value != "") {
            pageid = document.getElementById("ctl00_ContentPlaceHolder3_hfchildpageid").value;
            // alert(pageid);

            if (document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount") != null) {
                if (document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount").value != "") {
                    rowcount = document.getElementById("ctl00_ContentPlaceHolder3_hfrowcount").value;
                    // alert(rowcount);
                }
                else {
                    rowcount = 1;
                }


                if (document.getElementById("ctl00_ContentPlaceHolder3_hfrequiredfield") != null) {
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfrequiredfield").value != "") {
                        var strreqfields = document.getElementById("ctl00_ContentPlaceHolder3_hfrequiredfield").value;
                        // alert(strreqfields);

                        var strreq = new String(strreqfields);
                        // alert(strreq);
                        var myarray = strreq.split(",");
                        // alert("split ok");

                        for (var rowcnt = 1; rowcnt <= rowcount; rowcnt++) {
                            // alert(rowcnt);
                            for (var cnt = 0; cnt < myarray.length; cnt++) {

                                var mytext = myarray[cnt];
                                //  alert(mytext);
                                if (mytext != "") {

                                    var interarray = mytext.split(":");

                                    var controlid = pageid + "_" + interarray[0] + "_" + rowcnt;
                                    if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid) != null) {
                                        if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid).type == "text") {
                                            if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid).value == "") {
                                                // alert(controlid);
                                                if (document.getElementById("ctl00_ContentPlaceHolder3_lbl_message") != null) {
                                                    //alert("labelfound");
                                                    document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML = "empty";
                                                    document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML = "<img src=\"Images/error.gif\" alt=\"Error\"></img> &nbsp;" + interarray[1] + " in row " + rowcnt + " is mandatory field";


                                                    return false;
                                                }

                                            }


                                        }
                                        else if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid).type == "select-one") {
                                            // alert("dropdown");
                                            if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid).selectedIndex == -1) {
                                                // alert(controlid);
                                                if (document.getElementById("ctl00_ContentPlaceHolder3_lbl_message") != null) {


                                                    document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML = "<img src=\"Images/error.gif\" alt=\"Error\"></img> &nbsp;" + interarray[1] + " in row " + rowcnt + " is mandatory field";


                                                    return false;
                                                }

                                            }
                                            //alert("dropdown");
                                        }
                                        else if (document.getElementById("ctl00_ContentPlaceHolder3_" + controlid).type == "checkbox") {

                                        }

                                        // document.getElementById("DropDownList1").type text,select-one, checkbox    

                                    }

                                }
                            }

                        }

                    }
                }

                return true;
            }

        }
    }


}



////function validaterequiredfields()
////{
////    var pageid = "";
////    var rowcount = "";
////    if(document.getElementById("ctl00$ContentPlaceHolder3$hfchildpageid")!=null)
////    {
////        if(document.getElementById("ctl00$ContentPlaceHolder3$hfchildpageid").value!="")
////        {
////            pageid =  document.getElementById("ctl00$ContentPlaceHolder3$hfchildpageid").value;
////           // alert(pageid);
////            
////            if(document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount")!=null)
////            {
////                if(document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount").value !="")
////                {
////                    rowcount = document.getElementById("ctl00$ContentPlaceHolder3$hfrowcount").value;
////                   // alert(rowcount);
////                }
////                else
////                {
////                    rowcount =1;
////                }
////                
////                
////                if(document.getElementById("ctl00$ContentPlaceHolder3$hfrequiredfield")!=null)
////                {
////                    if(document.getElementById("ctl00$ContentPlaceHolder3$hfrequiredfield").value!="")
////                    {
////                        var strreqfields = document.getElementById("ctl00$ContentPlaceHolder3$hfrequiredfield").value;
////                       // alert(strreqfields);
////                
////                        var strreq = new String(strreqfields);
////                       // alert(strreq);
////                        var myarray = strreq.split(",");
////                       // alert("split ok");
////                
////                        for(var rowcnt=1;rowcnt<=rowcount;rowcnt++)
////                        {
////                       // alert(rowcnt);
////                            for(var cnt=0;cnt<myarray.length;cnt++)
////                            {
////                           
////                                var mytext = myarray[cnt];
////                              //  alert(mytext);
////                                if(mytext!="")
////                                {
////                                
////                                    var interarray = mytext.split(":");
////                                
////                                    var controlid = pageid+"_"+interarray[0]+"_"+rowcnt;
////                                    if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid)!=null)
////                                    {
////                                    if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid).type=="text")
////                                    {       
////                                        if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid).value =="")
////                                        {
////                                           // alert(controlid);
////                                            if(document.getElementById("ctl00_ContentPlaceHolder3_lbl_message")!=null)
////                                            {   
////                                            //alert("labelfound");
////                                               document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML="empty";
////                                               document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML= "<img src=\"Images/error.gif\" alt=\"Error\"></img> &nbsp;" +interarray[1]+" in row "+rowcnt+" is mandatory field";
////                                               
////                                               
////                                               return false;
////                                            }
////                                            
////                                        }
////                                        
////  
////                                    }
////                                    else if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid).type=="select-one")
////                                    {   
////                                   // alert("dropdown");
////                                           if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid).selectedIndex==-1)
////                                        {
////                                           // alert(controlid);
////                                            if(document.getElementById("ctl00_ContentPlaceHolder3_lbl_message")!=null)
////                                            {   
////                                            
////                                             
////                                               document.getElementById("ctl00_ContentPlaceHolder3_lbl_message").innerHTML="<img src=\"Images/error.gif\" alt=\"Error\"></img> &nbsp;"+ interarray[1]+" in row "+rowcnt+" is mandatory field";
////                                               
////                                               
////                                               return false;
////                                            }
////                                            
////                                        }
////                                        //alert("dropdown");
////                                    }
////                                    else if(document.getElementById("ctl00$ContentPlaceHolder3$"+controlid).type=="checkbox")
////                                    {
////                                        
////                                    }
////                                    
////                                    // document.getElementById("DropDownList1").type text,select-one, checkbox    
////                                        
////                                    }
////                                     
////                                }
////                            }
////                    
////                        }

////                    }
////                }
////                
////                return true;
////            }
////            
////        }
////    }
////    
////           
////}